<?php
/**
 * RadioMorningModel.class.php
 * 晨间电台模型
 * 
 * @author 	王中艺	<wangzy_smile@qq.com>
 * @date 	2017-04-27
 */

namespace Admin\Model;

class RadioMorningModel extends \Common\Model\RadioMorningModel {

	/**
	 * 电台详情
	 * @param 	$radioId
	 * @return 	$radioInfo
	 */
	function getItem($radioId){
		$radioInfo 	= $this->where('id = %d and status != -1', $radioId)
			->find();

		//字段重写
		$radioInfo['banner']	= C('SERVER_CDN').$radioInfo['banner'];
		$radioInfo['audio']		= C('SERVER_CDN').$radioInfo['audio'];
		$radioInfo['create_date']	= date('Y-m-d', $radioInfo['create_time']);
		$radioInfo['update_date']	= date('Y-m-d', $radioInfo['update_time']);

		return $radioInfo;
	}

	/**
	 * 更新电台数据
	 * @param 	$radioId
	 * @param 	$radioInfo
	 * @return 	$boolean
	 */
	function updateItem($radioId, $radioInfo){
		$radioInfo['update_time']	= time();

		$result 	= $this->where('id = %d', $radioId)->save($radioInfo);
		if($result == false){
			$this->errMsg 	= '晨间电台信息更新失败!';
			return false;
		}

		return true;
	}
}
